package com.xbts.screen.controller.workshop;

import com.xbts.common.core.constant.CacheConstants;
import com.xbts.common.core.constant.Constants;
import com.xbts.common.core.utils.StringUtils;
import com.xbts.common.core.web.controller.BaseController;
import com.xbts.common.core.web.domain.AjaxResult;
import com.xbts.common.core.web.domain.BaseHistogramResult;
import com.xbts.common.core.web.domain.BasePieChartResult;
import com.xbts.common.security.annotation.RequiresPermissions;
import com.xbts.screen.domain.vo.WorkshopPassRateRecordVO;
import com.xbts.screen.domain.workshop.vo.*;
import com.xbts.screen.service.IMaterialQualityService;
import com.xbts.screen.service.IWeVirtualDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 物料品质Controller
 */
@Api(tags = "物料品质")
@RestController
@RequestMapping("/materialQuality")
public class MaterialQualityController extends BaseController {


    @Autowired
    private IMaterialQualityService materialQualityService;
    /**
     * 物料种类抽检
     */
    @ApiOperation("物料种类抽检")
    @RequiresPermissions("workshop:materialQuality:materialTypeSampling")
    @GetMapping("/materialTypeSampling")
    public AjaxResult materialTypeSampling(){
        SamplingPassRateTrendVO vo = materialQualityService.materialTypeSampling();
        return success(vo);
    }
    /**
     * 抽检不良统计
     */
    @ApiOperation("抽检不良统计")
    @RequiresPermissions("workshop:materialQuality:samplingBadStatistics")
    @GetMapping("/samplingBadStatistics")
    public AjaxResult samplingBadStatistics(){
        List<BasePieChartResult> resultList = materialQualityService.samplingBadStatistics();
        return success(resultList);
    }
    /**
     * 抽检合格率趋势
     */
    @ApiOperation("抽检合格率趋势")
    @RequiresPermissions("workshop:materialQuality:samplingPassRateTrend")
    @GetMapping("/samplingPassRateTrend")
    public AjaxResult samplingPassRateTrend(){
        BaseHistogramResult result = materialQualityService.samplingPassRateTrend();
        return success(result);
    }

    /**
     * 料号批次合格率记录
     */
    @ApiOperation("料号批次合格率记录")
    @RequiresPermissions("workshop:materialQuality:passRateRecord")
    @GetMapping("/passRateRecord")
    public AjaxResult passRateRecord(){
        List<WorkshopPassRateRecordVO> voList = materialQualityService.passRateRecord();
        return success(voList);
    }
}
